﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Graphics;
using ReLogic.Utilities;
using Terraria.Audio;
using Terraria.GameContent.Liquid;
using Terraria.Graphics;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader.Audio;
using Terraria.ModLoader.Exceptions;
using Terraria.ModLoader.IO;
using Terraria.UI;
using Terraria.Utilities;

namespace Terraria.ModLoader
{
	// Token: 0x020001BC RID: 444
	public abstract class Mod
	{
		// Token: 0x1700013F RID: 319
		// (get) Token: 0x060011DF RID: 4575 RVA: 0x0000F077 File Offset: 0x0000D277
		// (set) Token: 0x060011E0 RID: 4576 RVA: 0x0000F07F File Offset: 0x0000D27F
		public TmodFile File { get; internal set; }

		// Token: 0x17000140 RID: 320
		// (get) Token: 0x060011E1 RID: 4577 RVA: 0x0000F088 File Offset: 0x0000D288
		// (set) Token: 0x060011E2 RID: 4578 RVA: 0x0000F090 File Offset: 0x0000D290
		public Assembly Code { get; internal set; }

		// Token: 0x17000141 RID: 321
		// (get) Token: 0x060011E3 RID: 4579 RVA: 0x0000F099 File Offset: 0x0000D299
		public virtual string Name
		{
			get
			{
				return this.File.name;
			}
		}

		// Token: 0x17000142 RID: 322
		// (get) Token: 0x060011E4 RID: 4580 RVA: 0x0000F0A6 File Offset: 0x0000D2A6
		public virtual Version tModLoaderVersion
		{
			get
			{
				return this.File.tModLoaderVersion;
			}
		}

		// Token: 0x17000143 RID: 323
		// (get) Token: 0x060011E5 RID: 4581 RVA: 0x0000F0B3 File Offset: 0x0000D2B3
		public virtual Version Version
		{
			get
			{
				return this.File.version;
			}
		}

		// Token: 0x17000144 RID: 324
		// (get) Token: 0x060011E6 RID: 4582 RVA: 0x0000F0C0 File Offset: 0x0000D2C0
		// (set) Token: 0x060011E7 RID: 4583 RVA: 0x0000F0C8 File Offset: 0x0000D2C8
		public ModProperties Properties { get; protected set; } = ModProperties.AutoLoadAll;

		// Token: 0x17000145 RID: 325
		// (get) Token: 0x060011E8 RID: 4584 RVA: 0x0000F0D1 File Offset: 0x0000D2D1
		// (set) Token: 0x060011E9 RID: 4585 RVA: 0x0000F0D9 File Offset: 0x0000D2D9
		public ModSide Side { get; internal set; }

		// Token: 0x17000146 RID: 326
		// (get) Token: 0x060011EA RID: 4586 RVA: 0x0000F0E2 File Offset: 0x0000D2E2
		// (set) Token: 0x060011EB RID: 4587 RVA: 0x0000F0EA File Offset: 0x0000D2EA
		public string DisplayName { get; internal set; }

		// Token: 0x17000147 RID: 327
		// (get) Token: 0x060011EC RID: 4588 RVA: 0x0000F0F3 File Offset: 0x0000D2F3
		public bool IsNetSynced
		{
			get
			{
				return this.netID >= 0;
			}
		}

		// Token: 0x060011ED RID: 4589 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void Load()
		{
		}

		// Token: 0x060011EE RID: 4590 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void PostSetupContent()
		{
		}

		// Token: 0x060011EF RID: 4591 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void Unload()
		{
		}

		// Token: 0x060011F0 RID: 4592 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void AddRecipeGroups()
		{
		}

		// Token: 0x060011F1 RID: 4593 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void AddRecipes()
		{
		}

		// Token: 0x060011F2 RID: 4594 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void PostAddRecipes()
		{
		}

		// Token: 0x060011F3 RID: 4595 RVA: 0x0040BDE8 File Offset: 0x00409FE8
		public virtual void LoadResourceFromStream(string path, int len, BinaryReader reader)
		{
			if (Main.dedServ)
			{
				return;
			}
			Interface.loadMods.SetSubProgressInit(path);
			string extension = Path.GetExtension(path);
			path = Path.ChangeExtension(path, null);
			if (extension == ".png" || extension == ".rawimg")
			{
				this.LoadTexture(path, len, reader, extension == ".rawimg");
				return;
			}
			if (extension == ".wav")
			{
				this.LoadWav(path, reader.ReadBytes(len));
				return;
			}
			if (extension == ".mp3")
			{
				this.LoadMP3(path, reader.ReadBytes(len));
				return;
			}
			if (!(extension == ".xnb"))
			{
				throw new ResourceLoadException(string.Format("Unknown streaming asset {0}{1}. ", path, extension), null);
			}
			if (path.StartsWith("Fonts/"))
			{
				this.LoadFont(path, reader.ReadBytes(len));
				return;
			}
			if (path.StartsWith("Effects/"))
			{
				this.LoadEffect(path, reader);
				return;
			}
			throw new ResourceLoadException(Language.GetTextValue("tModLoader.LoadErrorUnknownXNBFileHint", path), null);
		}

		// Token: 0x060011F4 RID: 4596 RVA: 0x0040BEE4 File Offset: 0x0040A0E4
		private void LoadTexture(string path, int len, BinaryReader reader, bool rawimg)
		{
			try
			{
				Task<Texture2D> task = rawimg ? ImageIO.RawToTexture2DAsync(Main.instance.GraphicsDevice, reader) : ImageIO.PngToTexture2DAsync(Main.instance.GraphicsDevice, new MemoryStream(reader.ReadBytes(len)));
				this.AsyncLoadQueue.Enqueue(task.ContinueWith(delegate(Task<Texture2D> t)
				{
					Texture2D result = t.Result;
					result.Name = this.Name + "/" + path;
					IDictionary<string, Texture2D> obj = this.textures;
					lock (obj)
					{
						this.textures[path] = result;
					}
				}));
			}
			catch (Exception inner)
			{
				throw new ResourceLoadException(Language.GetTextValue("tModLoader.LoadErrorTextureFailedToLoad", path), inner);
			}
		}

		// Token: 0x060011F5 RID: 4597 RVA: 0x0040BF80 File Offset: 0x0040A180
		private void LoadWav(string path, byte[] bytes)
		{
			try
			{
				if (path.StartsWith("Sounds/Music/"))
				{
					this.musics[path] = new MusicData(bytes, false);
				}
				else
				{
					this.sounds[path] = SoundEffect.FromStream(new MemoryStream(bytes));
				}
			}
			catch (Exception inner)
			{
				throw new ResourceLoadException(Language.GetTextValue("tModLoader.LoadErrorWavSoundFailedToLoad", path) + ((Main.engine == null) ? ("\n" + Language.GetTextValue("tModLoader.LoadErrorSoundFailedToLoadAudioDeviceHint")) : ""), inner);
			}
		}

		// Token: 0x060011F6 RID: 4598 RVA: 0x0040C014 File Offset: 0x0040A214
		private void LoadMP3(string path, byte[] bytes)
		{
			string text = string.Concat(new object[]
			{
				this.Name,
				"_",
				path.Replace('/', '_'),
				"_",
				this.Version,
				".wav"
			});
			WAVCacheIO.DeleteIfOlder(this.File.path, text);
			try
			{
				if (path.StartsWith("Sounds/Music/"))
				{
					if (ModLoader.musicStreamMode != 1)
					{
						this.musics[path] = new MusicData(bytes, true);
					}
					else
					{
						if (!WAVCacheIO.WAVCacheAvailable(text))
						{
							WAVCacheIO.CacheMP3(text, new MemoryStream(bytes));
						}
						this.musics[path] = new MusicData(Path.Combine(WAVCacheIO.ModCachePath, text));
					}
				}
				else
				{
					this.sounds[path] = (WAVCacheIO.WAVCacheAvailable(text) ? SoundEffect.FromStream(WAVCacheIO.GetWavStream(text)) : WAVCacheIO.CacheMP3(text, new MemoryStream(bytes)));
				}
			}
			catch (Exception inner)
			{
				throw new ResourceLoadException(Language.GetTextValue("tModLoader.LoadErrorMP3SoundFailedToLoad", path) + ((Main.engine == null) ? ("\n" + Language.GetTextValue("tModLoader.LoadErrorSoundFailedToLoadAudioDeviceHint")) : ""), inner);
			}
		}

		// Token: 0x060011F7 RID: 4599 RVA: 0x0040C150 File Offset: 0x0040A350
		private void LoadFont(string path, byte[] data)
		{
			string text = string.Concat(new object[]
			{
				this.Name,
				"_",
				path.Replace('/', '_'),
				"_",
				this.Version
			});
			string text2 = text + ".xnb";
			FontCacheIO.DeleteIfOlder(this.File.path, text2);
			if (!FontCacheIO.FontCacheAvailable(text2))
			{
				FileUtilities.WriteAllBytes(FontCacheIO.FontCachePath + Path.DirectorySeparatorChar.ToString() + text2, data, false);
			}
			try
			{
				this.fonts[path] = Main.instance.OurLoad<DynamicSpriteFont>(string.Concat(new string[]
				{
					"Fonts",
					Path.DirectorySeparatorChar.ToString(),
					"ModFonts",
					Path.DirectorySeparatorChar.ToString(),
					text
				}));
			}
			catch (Exception inner)
			{
				throw new ResourceLoadException(Language.GetTextValue("tModLoader.LoadErrorFontFailedToLoad", path), inner);
			}
		}

		// Token: 0x060011F8 RID: 4600 RVA: 0x0040C258 File Offset: 0x0040A458
		private void LoadEffect(string path, BinaryReader br)
		{
			try
			{
				char c = (char)br.ReadByte();
				char c2 = (char)br.ReadByte();
				char c3 = (char)br.ReadByte();
				char c4 = (char)br.ReadByte();
				byte b = br.ReadByte();
				byte b2 = br.ReadByte();
				uint num = br.ReadUInt32();
				if ((b2 & 128) != 0)
				{
					throw new Exception(Language.GetTextValue("tModLoader.LoadErrorCannotLoadCompressedEffects"));
				}
				int num2 = br.ReadVarInt();
				string text = br.ReadString();
				int num3 = br.ReadInt32();
				int num4 = br.ReadVarInt();
				int num5 = br.ReadVarInt();
				uint count = br.ReadUInt32();
				byte[] effectCode = br.ReadBytes((int)count);
				this.effects[path] = new Effect(Main.instance.GraphicsDevice, effectCode);
			}
			catch (Exception inner)
			{
				throw new ResourceLoadException(Language.GetTextValue("tModLoader.LoadErrorEffectFailedToLoad", path), inner);
			}
		}

		// Token: 0x060011F9 RID: 4601 RVA: 0x0040C334 File Offset: 0x0040A534
		internal void Autoload()
		{
			if (this.Code == null)
			{
				return;
			}
			Interface.loadMods.SetSubProgressInit(Language.GetTextValue("tModLoader.MSFinishingResourceLoading"));
			while (this.AsyncLoadQueue.Count > 0)
			{
				this.AsyncLoadQueue.Dequeue().Wait();
			}
			this.AutoloadLocalization();
			IList<Type> list = new List<Type>();
			IList<Type> list2 = new List<Type>();
			foreach (Type type2 in this.Code.GetTypes().OrderBy((Type type) => type.FullName, StringComparer.InvariantCulture))
			{
				if (!type2.IsAbstract && !(type2.GetConstructor(new Type[0]) == null))
				{
					if (type2.IsSubclassOf(typeof(ModItem)))
					{
						this.AutoloadItem(type2);
					}
					else if (type2.IsSubclassOf(typeof(GlobalItem)))
					{
						this.AutoloadGlobalItem(type2);
					}
					else if (type2.IsSubclassOf(typeof(ModPrefix)))
					{
						this.AutoloadPrefix(type2);
					}
					else if (type2.IsSubclassOf(typeof(ModDust)))
					{
						this.AutoloadDust(type2);
					}
					else if (type2.IsSubclassOf(typeof(ModTile)))
					{
						this.AutoloadTile(type2);
					}
					else if (type2.IsSubclassOf(typeof(GlobalTile)))
					{
						this.AutoloadGlobalTile(type2);
					}
					else if (type2.IsSubclassOf(typeof(ModTileEntity)))
					{
						this.AutoloadTileEntity(type2);
					}
					else if (type2.IsSubclassOf(typeof(ModWall)))
					{
						this.AutoloadWall(type2);
					}
					else if (type2.IsSubclassOf(typeof(GlobalWall)))
					{
						this.AutoloadGlobalWall(type2);
					}
					else if (type2.IsSubclassOf(typeof(ModProjectile)))
					{
						this.AutoloadProjectile(type2);
					}
					else if (type2.IsSubclassOf(typeof(GlobalProjectile)))
					{
						this.AutoloadGlobalProjectile(type2);
					}
					else if (type2.IsSubclassOf(typeof(ModNPC)))
					{
						this.AutoloadNPC(type2);
					}
					else if (type2.IsSubclassOf(typeof(GlobalNPC)))
					{
						this.AutoloadGlobalNPC(type2);
					}
					else if (type2.IsSubclassOf(typeof(ModPlayer)))
					{
						this.AutoloadPlayer(type2);
					}
					else if (type2.IsSubclassOf(typeof(ModBuff)))
					{
						this.AutoloadBuff(type2);
					}
					else if (type2.IsSubclassOf(typeof(GlobalBuff)))
					{
						this.AutoloadGlobalBuff(type2);
					}
					else if (type2.IsSubclassOf(typeof(ModMountData)))
					{
						this.AutoloadMountData(type2);
					}
					else if (type2.IsSubclassOf(typeof(ModGore)))
					{
						list.Add(type2);
					}
					else if (type2.IsSubclassOf(typeof(ModSound)))
					{
						list2.Add(type2);
					}
					else if (type2.IsSubclassOf(typeof(ModWorld)))
					{
						this.AutoloadModWorld(type2);
					}
					else if (type2.IsSubclassOf(typeof(ModUgBgStyle)))
					{
						this.AutoloadUgBgStyle(type2);
					}
					else if (type2.IsSubclassOf(typeof(ModSurfaceBgStyle)))
					{
						this.AutoloadSurfaceBgStyle(type2);
					}
					else if (type2.IsSubclassOf(typeof(GlobalBgStyle)))
					{
						this.AutoloadGlobalBgStyle(type2);
					}
					else if (type2.IsSubclassOf(typeof(ModWaterStyle)))
					{
						this.AutoloadWaterStyle(type2);
					}
					else if (type2.IsSubclassOf(typeof(ModWaterfallStyle)))
					{
						this.AutoloadWaterfallStyle(type2);
					}
					else if (type2.IsSubclassOf(typeof(GlobalRecipe)))
					{
						this.AutoloadGlobalRecipe(type2);
					}
					else if (type2.IsSubclassOf(typeof(ModCommand)))
					{
						this.AutoloadCommand(type2);
					}
				}
			}
			if (this.Properties.AutoloadGores)
			{
				this.AutoloadGores(list);
			}
			if (this.Properties.AutoloadSounds)
			{
				this.AutoloadSounds(list2);
			}
			if (this.Properties.AutoloadBackgrounds)
			{
				this.AutoloadBackgrounds();
			}
		}

		// Token: 0x060011FA RID: 4602 RVA: 0x0040C788 File Offset: 0x0040A988
		public void AddItem(string name, ModItem item)
		{
			if (!this.loading)
			{
				throw new Exception(Language.GetTextValue("tModLoader.LoadErrorAddItemOnlyInLoad"));
			}
			if (this.items.ContainsKey(name))
			{
				throw new Exception(Language.GetTextValue("tModLoader.LoadError2ModItemSameName", name));
			}
			item.mod = this;
			item.Name = name;
			item.DisplayName = this.GetOrCreateTranslation(string.Format("Mods.{0}.ItemName.{1}", this.Name, name), false);
			item.Tooltip = this.GetOrCreateTranslation(string.Format("Mods.{0}.ItemTooltip.{1}", this.Name, name), true);
			item.item.ResetStats(ItemLoader.ReserveItemID());
			item.item.modItem = item;
			this.items[name] = item;
			ItemLoader.items.Add(item);
		}

		// Token: 0x060011FB RID: 4603 RVA: 0x0040C84C File Offset: 0x0040AA4C
		public ModItem GetItem(string name)
		{
			ModItem result;
			if (!this.items.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x060011FC RID: 4604 RVA: 0x0000F101 File Offset: 0x0000D301
		public T GetItem<T>() where T : ModItem
		{
			return (T)((object)this.GetItem(typeof(T).Name));
		}

		// Token: 0x060011FD RID: 4605 RVA: 0x0000F11D File Offset: 0x0000D31D
		public int ItemType(string name)
		{
			ModItem item = this.GetItem(name);
			if (item == null)
			{
				return 0;
			}
			return item.item.type;
		}

		// Token: 0x060011FE RID: 4606 RVA: 0x0000F136 File Offset: 0x0000D336
		public int ItemType<T>() where T : ModItem
		{
			return this.ItemType(typeof(T).Name);
		}

		// Token: 0x060011FF RID: 4607 RVA: 0x0040C86C File Offset: 0x0040AA6C
		public void AddGlobalItem(string name, GlobalItem globalItem)
		{
			if (!this.loading)
			{
				throw new Exception("AddGlobalItem can only be called from Mod.Load or Mod.Autoload");
			}
			ItemLoader.VerifyGlobalItem(globalItem);
			globalItem.mod = this;
			globalItem.Name = name;
			this.globalItems[name] = globalItem;
			globalItem.index = ItemLoader.globalItems.Count;
			ItemLoader.globalIndexes[this.Name + ":" + name] = ItemLoader.globalItems.Count;
			if (ItemLoader.globalIndexesByType.ContainsKey(globalItem.GetType()))
			{
				ItemLoader.globalIndexesByType[globalItem.GetType()] = -1;
			}
			else
			{
				ItemLoader.globalIndexesByType[globalItem.GetType()] = ItemLoader.globalItems.Count;
			}
			ItemLoader.globalItems.Add(globalItem);
		}

		// Token: 0x06001200 RID: 4608 RVA: 0x0040C92C File Offset: 0x0040AB2C
		public GlobalItem GetGlobalItem(string name)
		{
			GlobalItem result;
			if (!this.globalItems.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x06001201 RID: 4609 RVA: 0x0000F14D File Offset: 0x0000D34D
		public T GetGlobalItem<T>() where T : GlobalItem
		{
			return (T)((object)this.GetGlobalItem(typeof(T).Name));
		}

		// Token: 0x06001202 RID: 4610 RVA: 0x0000F169 File Offset: 0x0000D369
		public int AddEquipTexture(ModItem item, EquipType type, string name, string texture, string armTexture = "", string femaleTexture = "")
		{
			return this.AddEquipTexture(new EquipTexture(), item, type, name, texture, armTexture, femaleTexture);
		}

		// Token: 0x06001203 RID: 4611 RVA: 0x0040C94C File Offset: 0x0040AB4C
		public int AddEquipTexture(EquipTexture equipTexture, ModItem item, EquipType type, string name, string texture, string armTexture = "", string femaleTexture = "")
		{
			if (!this.loading)
			{
				throw new Exception("AddEquipTexture can only be called from Mod.Load or Mod.Autoload");
			}
			ModLoader.GetTexture(texture);
			equipTexture.Texture = texture;
			equipTexture.mod = this;
			equipTexture.Name = name;
			equipTexture.Type = type;
			equipTexture.item = item;
			int num = equipTexture.Slot = EquipLoader.ReserveEquipID(type);
			EquipLoader.equipTextures[type][num] = equipTexture;
			this.equipTextures[Tuple.Create<string, EquipType>(name, type)] = equipTexture;
			if (type == EquipType.Body)
			{
				if (femaleTexture == null || !ModLoader.TextureExists(femaleTexture))
				{
					femaleTexture = texture;
				}
				EquipLoader.femaleTextures[num] = femaleTexture;
				ModLoader.GetTexture(armTexture);
				EquipLoader.armTextures[num] = armTexture;
			}
			if (item != null)
			{
				IDictionary<EquipType, int> dictionary;
				if (!EquipLoader.idToSlot.TryGetValue(item.item.type, out dictionary))
				{
					dictionary = (EquipLoader.idToSlot[item.item.type] = new Dictionary<EquipType, int>());
				}
				dictionary[type] = num;
				if (type == EquipType.Head || type == EquipType.Body || type == EquipType.Legs)
				{
					EquipLoader.slotToId[type][num] = item.item.type;
				}
			}
			return num;
		}

		// Token: 0x06001204 RID: 4612 RVA: 0x0040CA70 File Offset: 0x0040AC70
		public EquipTexture GetEquipTexture(string name, EquipType type)
		{
			EquipTexture result;
			if (!this.equipTextures.TryGetValue(Tuple.Create<string, EquipType>(name, type), out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x06001205 RID: 4613 RVA: 0x0000F17F File Offset: 0x0000D37F
		public int GetEquipSlot(string name, EquipType type)
		{
			EquipTexture equipTexture = this.GetEquipTexture(name, type);
			if (equipTexture == null)
			{
				return -1;
			}
			return equipTexture.Slot;
		}

		// Token: 0x06001206 RID: 4614 RVA: 0x0000F194 File Offset: 0x0000D394
		public sbyte GetAccessorySlot(string name, EquipType type)
		{
			return (sbyte)this.GetEquipSlot(name, type);
		}

		// Token: 0x06001207 RID: 4615 RVA: 0x0040CA98 File Offset: 0x0040AC98
		private void AutoloadItem(Type type)
		{
			ModItem modItem = (ModItem)Activator.CreateInstance(type);
			modItem.mod = this;
			string name = type.Name;
			if (modItem.Autoload(ref name))
			{
				this.AddItem(name, modItem);
				AutoloadEquip attribute = AttributeUtilities.GetAttribute<AutoloadEquip>(type);
				if (attribute != null)
				{
					foreach (EquipType equipType in attribute.equipTypes)
					{
						this.AddEquipTexture(modItem, equipType, modItem.Name, modItem.Texture + "_" + equipType, modItem.Texture + "_Arms", modItem.Texture + "_FemaleBody");
					}
				}
			}
		}

		// Token: 0x06001208 RID: 4616 RVA: 0x0040CB44 File Offset: 0x0040AD44
		private void AutoloadGlobalItem(Type type)
		{
			GlobalItem globalItem = (GlobalItem)Activator.CreateInstance(type);
			globalItem.mod = this;
			string name = type.Name;
			if (globalItem.Autoload(ref name))
			{
				this.AddGlobalItem(name, globalItem);
			}
		}

		// Token: 0x06001209 RID: 4617 RVA: 0x0040CB80 File Offset: 0x0040AD80
		public void AddPrefix(string name, ModPrefix prefix)
		{
			if (!this.loading)
			{
				throw new Exception("AddPrefix can only be called from Mod.Load or Mod.Autoload");
			}
			if (this.prefixes.ContainsKey(name))
			{
				throw new Exception("You tried to add 2 ModPrefixes with the same name: " + name + ". Maybe 2 classes share a classname but in different namespaces while autoloading or you manually called AddPrefix with 2 prefixes of the same name.");
			}
			prefix.mod = this;
			prefix.Name = name;
			prefix.DisplayName = this.GetOrCreateTranslation(string.Format("Mods.{0}.Prefix.{1}", this.Name, name), false);
			prefix.Type = ModPrefix.ReservePrefixID();
			this.prefixes[name] = prefix;
			ModPrefix.prefixes.Add(prefix);
			ModPrefix.categoryPrefixes[prefix.Category].Add(prefix);
		}

		// Token: 0x0600120A RID: 4618 RVA: 0x0040CC2C File Offset: 0x0040AE2C
		public ModPrefix GetPrefix(string name)
		{
			ModPrefix result;
			if (!this.prefixes.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x0600120B RID: 4619 RVA: 0x0000F19F File Offset: 0x0000D39F
		public T GetPrefix<T>() where T : ModPrefix
		{
			return (T)((object)this.GetPrefix(typeof(T).Name));
		}

		// Token: 0x0600120C RID: 4620 RVA: 0x0000F1BB File Offset: 0x0000D3BB
		public byte PrefixType(string name)
		{
			ModPrefix prefix = this.GetPrefix(name);
			if (prefix == null)
			{
				return 0;
			}
			return prefix.Type;
		}

		// Token: 0x0600120D RID: 4621 RVA: 0x0000F1CF File Offset: 0x0000D3CF
		public byte PrefixType<T>() where T : ModPrefix
		{
			return this.PrefixType(typeof(T).Name);
		}

		// Token: 0x0600120E RID: 4622 RVA: 0x0040CC4C File Offset: 0x0040AE4C
		private void AutoloadPrefix(Type type)
		{
			ModPrefix modPrefix = (ModPrefix)Activator.CreateInstance(type);
			modPrefix.mod = this;
			string name = type.Name;
			if (modPrefix.Autoload(ref name))
			{
				this.AddPrefix(name, modPrefix);
			}
		}

		// Token: 0x0600120F RID: 4623 RVA: 0x0040CC88 File Offset: 0x0040AE88
		public void AddDust(string name, ModDust dust, string texture = "")
		{
			if (!this.loading)
			{
				throw new Exception("AddDust can only be called from Mod.Load or Mod.Autoload");
			}
			dust.mod = this;
			dust.Name = name;
			dust.Type = ModDust.ReserveDustID();
			dust.Texture = ((!string.IsNullOrEmpty(texture)) ? ModLoader.GetTexture(texture) : Main.dustTexture);
			this.dusts[name] = dust;
			ModDust.dusts.Add(dust);
		}

		// Token: 0x06001210 RID: 4624 RVA: 0x0040CCF4 File Offset: 0x0040AEF4
		public ModDust GetDust(string name)
		{
			ModDust result;
			if (!this.dusts.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x06001211 RID: 4625 RVA: 0x0000F1E6 File Offset: 0x0000D3E6
		public T GetDust<T>() where T : ModDust
		{
			return (T)((object)this.GetDust(typeof(T).Name));
		}

		// Token: 0x06001212 RID: 4626 RVA: 0x0000F202 File Offset: 0x0000D402
		public int DustType(string name)
		{
			ModDust dust = this.GetDust(name);
			if (dust == null)
			{
				return 0;
			}
			return dust.Type;
		}

		// Token: 0x06001213 RID: 4627 RVA: 0x0000F216 File Offset: 0x0000D416
		public int DustType<T>() where T : ModDust
		{
			return this.DustType(typeof(T).Name);
		}

		// Token: 0x06001214 RID: 4628 RVA: 0x0040CD14 File Offset: 0x0040AF14
		private void AutoloadDust(Type type)
		{
			ModDust modDust = (ModDust)Activator.CreateInstance(type);
			modDust.mod = this;
			string name = type.Name;
			string texture = (type.Namespace + "." + type.Name).Replace('.', '/');
			if (modDust.Autoload(ref name, ref texture))
			{
				this.AddDust(name, modDust, texture);
			}
		}

		// Token: 0x06001215 RID: 4629 RVA: 0x0040CD70 File Offset: 0x0040AF70
		public void AddTile(string name, ModTile tile, string texture)
		{
			if (!this.loading)
			{
				throw new Exception("AddItem can only be called from Mod.Load or Mod.Autoload");
			}
			if (this.tiles.ContainsKey(name))
			{
				throw new Exception("You tried to add 2 ModTile with the same name: " + name + ". Maybe 2 classes share a classname but in different namespaces while autoloading or you manually called AddTile with 2 tiles of the same name.");
			}
			tile.mod = this;
			tile.Name = name;
			tile.Type = (ushort)TileLoader.ReserveTileID();
			tile.texture = texture;
			this.tiles[name] = tile;
			TileLoader.tiles.Add(tile);
		}

		// Token: 0x06001216 RID: 4630 RVA: 0x0040CDF0 File Offset: 0x0040AFF0
		public ModTile GetTile(string name)
		{
			ModTile result;
			if (!this.tiles.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x06001217 RID: 4631 RVA: 0x0000F22D File Offset: 0x0000D42D
		public T GetTile<T>() where T : ModTile
		{
			return (T)((object)this.GetTile(typeof(T).Name));
		}

		// Token: 0x06001218 RID: 4632 RVA: 0x0000F249 File Offset: 0x0000D449
		public int TileType(string name)
		{
			ModTile tile = this.GetTile(name);
			if (tile == null)
			{
				return 0;
			}
			return (int)tile.Type;
		}

		// Token: 0x06001219 RID: 4633 RVA: 0x0000F25D File Offset: 0x0000D45D
		public int TileType<T>() where T : ModTile
		{
			return this.TileType(typeof(T).Name);
		}

		// Token: 0x0600121A RID: 4634 RVA: 0x0000F274 File Offset: 0x0000D474
		public void AddGlobalTile(string name, GlobalTile globalTile)
		{
			if (!this.loading)
			{
				throw new Exception("AddGlobalTile can only be called from Mod.Load or Mod.Autoload");
			}
			globalTile.mod = this;
			globalTile.Name = name;
			this.globalTiles[name] = globalTile;
			TileLoader.globalTiles.Add(globalTile);
		}

		// Token: 0x0600121B RID: 4635 RVA: 0x0040CE10 File Offset: 0x0040B010
		public GlobalTile GetGlobalTile(string name)
		{
			GlobalTile result;
			if (!this.globalTiles.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x0600121C RID: 4636 RVA: 0x0000F2AF File Offset: 0x0000D4AF
		public T GetGlobalTile<T>() where T : GlobalTile
		{
			return (T)((object)this.GetGlobalTile(typeof(T).Name));
		}

		// Token: 0x0600121D RID: 4637 RVA: 0x0040CE30 File Offset: 0x0040B030
		private void AutoloadTile(Type type)
		{
			ModTile modTile = (ModTile)Activator.CreateInstance(type);
			modTile.mod = this;
			string name = type.Name;
			string texture = (type.Namespace + "." + type.Name).Replace('.', '/');
			if (modTile.Autoload(ref name, ref texture))
			{
				this.AddTile(name, modTile, texture);
			}
		}

		// Token: 0x0600121E RID: 4638 RVA: 0x0040CE8C File Offset: 0x0040B08C
		private void AutoloadGlobalTile(Type type)
		{
			GlobalTile globalTile = (GlobalTile)Activator.CreateInstance(type);
			globalTile.mod = this;
			string name = type.Name;
			if (globalTile.Autoload(ref name))
			{
				this.AddGlobalTile(name, globalTile);
			}
		}

		// Token: 0x0600121F RID: 4639 RVA: 0x0040CEC8 File Offset: 0x0040B0C8
		public void AddTileEntity(string name, ModTileEntity entity)
		{
			if (!this.loading)
			{
				throw new Exception("AddTileEntity can only be called from Mod.Load or Mod.Autoload");
			}
			int num = ModTileEntity.ReserveTileEntityID();
			entity.mod = this;
			entity.Name = name;
			entity.Type = num;
			entity.type = (byte)num;
			this.tileEntities[name] = entity;
			ModTileEntity.tileEntities.Add(entity);
		}

		// Token: 0x06001220 RID: 4640 RVA: 0x0040CF24 File Offset: 0x0040B124
		public ModTileEntity GetTileEntity(string name)
		{
			ModTileEntity result;
			if (!this.tileEntities.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x06001221 RID: 4641 RVA: 0x0000F2CB File Offset: 0x0000D4CB
		public T GetTileEntity<T>() where T : ModTileEntity
		{
			return (T)((object)this.GetTileEntity(typeof(T).Name));
		}

		// Token: 0x06001222 RID: 4642 RVA: 0x0000F2E7 File Offset: 0x0000D4E7
		public int TileEntityType(string name)
		{
			ModTileEntity tileEntity = this.GetTileEntity(name);
			if (tileEntity == null)
			{
				return -1;
			}
			return tileEntity.Type;
		}

		// Token: 0x06001223 RID: 4643 RVA: 0x0000F2FB File Offset: 0x0000D4FB
		public int TileEntityType<T>() where T : ModTileEntity
		{
			return this.TileEntityType(typeof(T).Name);
		}

		// Token: 0x06001224 RID: 4644 RVA: 0x0040CF44 File Offset: 0x0040B144
		private void AutoloadTileEntity(Type type)
		{
			ModTileEntity modTileEntity = (ModTileEntity)Activator.CreateInstance(type);
			modTileEntity.mod = this;
			string name = type.Name;
			if (modTileEntity.Autoload(ref name))
			{
				this.AddTileEntity(name, modTileEntity);
			}
		}

		// Token: 0x06001225 RID: 4645 RVA: 0x0040CF80 File Offset: 0x0040B180
		public void AddWall(string name, ModWall wall, string texture)
		{
			if (!this.loading)
			{
				throw new Exception("AddWall can only be called from Mod.Load or Mod.Autoload");
			}
			wall.mod = this;
			wall.Name = name;
			wall.Type = (ushort)WallLoader.ReserveWallID();
			wall.texture = texture;
			this.walls[name] = wall;
			WallLoader.walls.Add(wall);
		}

		// Token: 0x06001226 RID: 4646 RVA: 0x0040CFDC File Offset: 0x0040B1DC
		public ModWall GetWall(string name)
		{
			ModWall result;
			if (!this.walls.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x06001227 RID: 4647 RVA: 0x0000F312 File Offset: 0x0000D512
		public T GetWall<T>() where T : ModWall
		{
			return (T)((object)this.GetWall(typeof(T).Name));
		}

		// Token: 0x06001228 RID: 4648 RVA: 0x0000F32E File Offset: 0x0000D52E
		public int WallType(string name)
		{
			ModWall wall = this.GetWall(name);
			if (wall == null)
			{
				return 0;
			}
			return (int)wall.Type;
		}

		// Token: 0x06001229 RID: 4649 RVA: 0x0000F342 File Offset: 0x0000D542
		public int WallType<T>() where T : ModWall
		{
			return this.WallType(typeof(T).Name);
		}

		// Token: 0x0600122A RID: 4650 RVA: 0x0000F359 File Offset: 0x0000D559
		public void AddGlobalWall(string name, GlobalWall globalWall)
		{
			if (!this.loading)
			{
				throw new Exception("AddGlobalWall can only be called from Mod.Load or Mod.Autoload");
			}
			globalWall.mod = this;
			globalWall.Name = name;
			this.globalWalls[name] = globalWall;
			WallLoader.globalWalls.Add(globalWall);
		}

		// Token: 0x0600122B RID: 4651 RVA: 0x0040CFFC File Offset: 0x0040B1FC
		public GlobalWall GetGlobalWall(string name)
		{
			GlobalWall result;
			if (!this.globalWalls.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x0600122C RID: 4652 RVA: 0x0000F394 File Offset: 0x0000D594
		public T GetGlobalWall<T>() where T : GlobalWall
		{
			return (T)((object)this.GetGlobalWall(typeof(T).Name));
		}

		// Token: 0x0600122D RID: 4653 RVA: 0x0040D01C File Offset: 0x0040B21C
		private void AutoloadWall(Type type)
		{
			ModWall modWall = (ModWall)Activator.CreateInstance(type);
			modWall.mod = this;
			string name = type.Name;
			string texture = (type.Namespace + "." + type.Name).Replace('.', '/');
			if (modWall.Autoload(ref name, ref texture))
			{
				this.AddWall(name, modWall, texture);
			}
		}

		// Token: 0x0600122E RID: 4654 RVA: 0x0040D078 File Offset: 0x0040B278
		private void AutoloadGlobalWall(Type type)
		{
			GlobalWall globalWall = (GlobalWall)Activator.CreateInstance(type);
			globalWall.mod = this;
			string name = type.Name;
			if (globalWall.Autoload(ref name))
			{
				this.AddGlobalWall(name, globalWall);
			}
		}

		// Token: 0x0600122F RID: 4655 RVA: 0x0040D0B4 File Offset: 0x0040B2B4
		public void AddProjectile(string name, ModProjectile projectile)
		{
			if (!this.loading)
			{
				throw new Exception("AddProjectile can only be called from Mod.Load or Mod.Autoload");
			}
			if (this.projectiles.ContainsKey(name))
			{
				throw new Exception("You tried to add 2 ModProjectile with the same name: " + name + ". Maybe 2 classes share a classname but in different namespaces while autoloading or you manually called AddProjectile with 2 projectiles of the same name.");
			}
			projectile.mod = this;
			projectile.Name = name;
			projectile.projectile.type = ProjectileLoader.ReserveProjectileID();
			projectile.DisplayName = this.GetOrCreateTranslation(string.Format("Mods.{0}.ProjectileName.{1}", this.Name, name), false);
			this.projectiles[name] = projectile;
			ProjectileLoader.projectiles.Add(projectile);
		}

		// Token: 0x06001230 RID: 4656 RVA: 0x0040D14C File Offset: 0x0040B34C
		public ModProjectile GetProjectile(string name)
		{
			ModProjectile result;
			if (!this.projectiles.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x06001231 RID: 4657 RVA: 0x0000F3B0 File Offset: 0x0000D5B0
		public T GetProjectile<T>() where T : ModProjectile
		{
			return (T)((object)this.GetProjectile(typeof(T).Name));
		}

		// Token: 0x06001232 RID: 4658 RVA: 0x0000F3CC File Offset: 0x0000D5CC
		public int ProjectileType(string name)
		{
			ModProjectile projectile = this.GetProjectile(name);
			if (projectile == null)
			{
				return 0;
			}
			return projectile.projectile.type;
		}

		// Token: 0x06001233 RID: 4659 RVA: 0x0000F3E5 File Offset: 0x0000D5E5
		public int ProjectileType<T>() where T : ModProjectile
		{
			return this.ProjectileType(typeof(T).Name);
		}

		// Token: 0x06001234 RID: 4660 RVA: 0x0040D16C File Offset: 0x0040B36C
		public void AddGlobalProjectile(string name, GlobalProjectile globalProjectile)
		{
			if (!this.loading)
			{
				throw new Exception("AddGlobalProjectile can only be called from Mod.Load or Mod.Autoload");
			}
			ProjectileLoader.VerifyGlobalProjectile(globalProjectile);
			globalProjectile.mod = this;
			globalProjectile.Name = name;
			this.globalProjectiles[name] = globalProjectile;
			globalProjectile.index = ProjectileLoader.globalProjectiles.Count;
			ProjectileLoader.globalIndexes[this.Name + ":" + name] = ProjectileLoader.globalProjectiles.Count;
			if (ProjectileLoader.globalIndexesByType.ContainsKey(globalProjectile.GetType()))
			{
				ProjectileLoader.globalIndexesByType[globalProjectile.GetType()] = -1;
			}
			else
			{
				ProjectileLoader.globalIndexesByType[globalProjectile.GetType()] = ProjectileLoader.globalProjectiles.Count;
			}
			ProjectileLoader.globalProjectiles.Add(globalProjectile);
		}

		// Token: 0x06001235 RID: 4661 RVA: 0x0040D22C File Offset: 0x0040B42C
		public GlobalProjectile GetGlobalProjectile(string name)
		{
			GlobalProjectile result;
			if (!this.globalProjectiles.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x06001236 RID: 4662 RVA: 0x0000F3FC File Offset: 0x0000D5FC
		public T GetGlobalProjectile<T>() where T : GlobalProjectile
		{
			return (T)((object)this.GetGlobalProjectile(typeof(T).Name));
		}

		// Token: 0x06001237 RID: 4663 RVA: 0x0040D24C File Offset: 0x0040B44C
		private void AutoloadProjectile(Type type)
		{
			ModProjectile modProjectile = (ModProjectile)Activator.CreateInstance(type);
			modProjectile.mod = this;
			string name = type.Name;
			string text = (type.Namespace + "." + type.Name).Replace('.', '/');
			if (modProjectile.Autoload(ref name))
			{
				this.AddProjectile(name, modProjectile);
			}
		}

		// Token: 0x06001238 RID: 4664 RVA: 0x0040D2A8 File Offset: 0x0040B4A8
		private void AutoloadGlobalProjectile(Type type)
		{
			GlobalProjectile globalProjectile = (GlobalProjectile)Activator.CreateInstance(type);
			globalProjectile.mod = this;
			string name = type.Name;
			if (globalProjectile.Autoload(ref name))
			{
				this.AddGlobalProjectile(name, globalProjectile);
			}
		}

		// Token: 0x06001239 RID: 4665 RVA: 0x0040D2E4 File Offset: 0x0040B4E4
		public void AddNPC(string name, ModNPC npc)
		{
			if (!this.loading)
			{
				throw new Exception("AddNPC can only be called from Mod.Load or Mod.Autoload");
			}
			if (this.npcs.ContainsKey(name))
			{
				throw new Exception("You tried to add 2 ModNPC with the same name: " + name + ". Maybe 2 classes share a classname but in different namespaces while autoloading or you manually called AddNPC with 2 npcs of the same name.");
			}
			npc.mod = this;
			npc.Name = name;
			npc.npc.type = NPCLoader.ReserveNPCID();
			npc.DisplayName = this.GetOrCreateTranslation(string.Format("Mods.{0}.NPCName.{1}", this.Name, name), false);
			this.npcs[name] = npc;
			NPCLoader.npcs.Add(npc);
		}

		// Token: 0x0600123A RID: 4666 RVA: 0x0040D37C File Offset: 0x0040B57C
		public ModNPC GetNPC(string name)
		{
			ModNPC result;
			if (!this.npcs.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x0600123B RID: 4667 RVA: 0x0000F418 File Offset: 0x0000D618
		public T GetNPC<T>() where T : ModNPC
		{
			return (T)((object)this.GetNPC(typeof(T).Name));
		}

		// Token: 0x0600123C RID: 4668 RVA: 0x0000F434 File Offset: 0x0000D634
		public int NPCType(string name)
		{
			ModNPC npc = this.GetNPC(name);
			if (npc == null)
			{
				return 0;
			}
			return npc.npc.type;
		}

		// Token: 0x0600123D RID: 4669 RVA: 0x0000F44D File Offset: 0x0000D64D
		public int NPCType<T>() where T : ModNPC
		{
			return this.NPCType(typeof(T).Name);
		}

		// Token: 0x0600123E RID: 4670 RVA: 0x0040D39C File Offset: 0x0040B59C
		public void AddGlobalNPC(string name, GlobalNPC globalNPC)
		{
			if (!this.loading)
			{
				throw new Exception("AddGlobalNPC can only be called from Mod.Load or Mod.Autoload");
			}
			NPCLoader.VerifyGlobalNPC(globalNPC);
			globalNPC.mod = this;
			globalNPC.Name = name;
			this.globalNPCs[name] = globalNPC;
			globalNPC.index = NPCLoader.globalNPCs.Count;
			NPCLoader.globalIndexes[this.Name + ":" + name] = NPCLoader.globalNPCs.Count;
			if (NPCLoader.globalIndexesByType.ContainsKey(globalNPC.GetType()))
			{
				NPCLoader.globalIndexesByType[globalNPC.GetType()] = -1;
			}
			else
			{
				NPCLoader.globalIndexesByType[globalNPC.GetType()] = NPCLoader.globalNPCs.Count;
			}
			NPCLoader.globalNPCs.Add(globalNPC);
		}

		// Token: 0x0600123F RID: 4671 RVA: 0x0040D45C File Offset: 0x0040B65C
		public GlobalNPC GetGlobalNPC(string name)
		{
			GlobalNPC result;
			if (!this.globalNPCs.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x06001240 RID: 4672 RVA: 0x0000F464 File Offset: 0x0000D664
		public T GetGlobalNPC<T>() where T : GlobalNPC
		{
			return (T)((object)this.GetGlobalNPC(typeof(T).Name));
		}

		// Token: 0x06001241 RID: 4673 RVA: 0x0040D47C File Offset: 0x0040B67C
		public void AddNPCHeadTexture(int npcType, string texture)
		{
			if (!this.loading)
			{
				throw new Exception("AddNPCHeadTexture can only be called from Mod.Load or Mod.Autoload");
			}
			int num = NPCHeadLoader.ReserveHeadSlot();
			NPCHeadLoader.heads[texture] = num;
			if (!Main.dedServ)
			{
				ModLoader.GetTexture(texture);
			}
			NPCHeadLoader.npcToHead[npcType] = num;
			NPCHeadLoader.headToNPC[num] = npcType;
		}

		// Token: 0x06001242 RID: 4674 RVA: 0x0040D4D4 File Offset: 0x0040B6D4
		public void AddBossHeadTexture(string texture, int npcType = -1)
		{
			if (!this.loading)
			{
				throw new Exception("AddBossHeadTexture can only be called from Mod.Load or Mod.Autoload");
			}
			int value = NPCHeadLoader.ReserveBossHeadSlot(texture);
			NPCHeadLoader.bossHeads[texture] = value;
			ModLoader.GetTexture(texture);
			if (npcType >= 0)
			{
				NPCHeadLoader.npcToBossHead[npcType] = value;
			}
		}

		// Token: 0x06001243 RID: 4675 RVA: 0x0040D520 File Offset: 0x0040B720
		private void AutoloadNPC(Type type)
		{
			ModNPC modNPC = (ModNPC)Activator.CreateInstance(type);
			modNPC.mod = this;
			string name = type.Name;
			if (modNPC.Autoload(ref name))
			{
				this.AddNPC(name, modNPC);
				string texture = modNPC.Texture;
				AutoloadHead attribute = AttributeUtilities.GetAttribute<AutoloadHead>(type);
				if (attribute != null)
				{
					string headTexture = modNPC.HeadTexture;
					this.AddNPCHeadTexture(modNPC.npc.type, headTexture);
				}
				AutoloadBossHead attribute2 = AttributeUtilities.GetAttribute<AutoloadBossHead>(type);
				if (attribute2 != null)
				{
					string bossHeadTexture = modNPC.BossHeadTexture;
					this.AddBossHeadTexture(bossHeadTexture, modNPC.npc.type);
				}
			}
		}

		// Token: 0x06001244 RID: 4676 RVA: 0x0040D5AC File Offset: 0x0040B7AC
		private void AutoloadGlobalNPC(Type type)
		{
			GlobalNPC globalNPC = (GlobalNPC)Activator.CreateInstance(type);
			globalNPC.mod = this;
			string name = type.Name;
			if (globalNPC.Autoload(ref name))
			{
				this.AddGlobalNPC(name, globalNPC);
			}
		}

		// Token: 0x06001245 RID: 4677 RVA: 0x0000F480 File Offset: 0x0000D680
		public void AddPlayer(string name, ModPlayer player)
		{
			if (!this.loading)
			{
				throw new Exception("AddPlayer can only be called from Mod.Load or Mod.Autoload");
			}
			player.mod = this;
			player.Name = name;
			this.players[name] = player;
			PlayerHooks.Add(player);
		}

		// Token: 0x06001246 RID: 4678 RVA: 0x0040D5E8 File Offset: 0x0040B7E8
		private void AutoloadPlayer(Type type)
		{
			ModPlayer modPlayer = (ModPlayer)Activator.CreateInstance(type);
			modPlayer.mod = this;
			string name = type.Name;
			if (modPlayer.Autoload(ref name))
			{
				this.AddPlayer(name, modPlayer);
			}
		}

		// Token: 0x06001247 RID: 4679 RVA: 0x0040D624 File Offset: 0x0040B824
		public void AddBuff(string name, ModBuff buff, string texture)
		{
			if (!this.loading)
			{
				throw new Exception("AddBuff can only be called from Mod.Load or Mod.Autoload");
			}
			if (this.buffs.ContainsKey(name))
			{
				throw new Exception("You tried to add 2 ModBuff with the same name: " + name + ". Maybe 2 classes share a classname but in different namespaces while autoloading or you manually called AddBuff with 2 buffs of the same name.");
			}
			buff.mod = this;
			buff.Name = name;
			buff.Type = BuffLoader.ReserveBuffID();
			buff.texture = texture;
			buff.DisplayName = this.GetOrCreateTranslation(string.Format("Mods.{0}.BuffName.{1}", this.Name, name), false);
			buff.Description = this.GetOrCreateTranslation(string.Format("Mods.{0}.BuffDescription.{1}", this.Name, name), false);
			this.buffs[name] = buff;
			BuffLoader.buffs.Add(buff);
		}

		// Token: 0x06001248 RID: 4680 RVA: 0x0000F4B6 File Offset: 0x0000D6B6
		internal ModTranslation GetOrCreateTranslation(string key, bool defaultEmpty = false)
		{
			key = key.Replace(" ", "_");
			if (this.translations.ContainsKey(key))
			{
				return this.translations[key];
			}
			return new ModTranslation(key, defaultEmpty);
		}

		// Token: 0x06001249 RID: 4681 RVA: 0x0040D6DC File Offset: 0x0040B8DC
		public ModBuff GetBuff(string name)
		{
			ModBuff result;
			if (!this.buffs.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x0600124A RID: 4682 RVA: 0x0000F4EC File Offset: 0x0000D6EC
		public T GetBuff<T>() where T : ModBuff
		{
			return (T)((object)this.GetBuff(typeof(T).Name));
		}

		// Token: 0x0600124B RID: 4683 RVA: 0x0000F508 File Offset: 0x0000D708
		public int BuffType(string name)
		{
			ModBuff buff = this.GetBuff(name);
			if (buff == null)
			{
				return 0;
			}
			return buff.Type;
		}

		// Token: 0x0600124C RID: 4684 RVA: 0x0000F51C File Offset: 0x0000D71C
		public int BuffType<T>() where T : ModBuff
		{
			return this.BuffType(typeof(T).Name);
		}

		// Token: 0x0600124D RID: 4685 RVA: 0x0000F533 File Offset: 0x0000D733
		public void AddGlobalBuff(string name, GlobalBuff globalBuff)
		{
			globalBuff.mod = this;
			globalBuff.Name = name;
			this.globalBuffs[name] = globalBuff;
			BuffLoader.globalBuffs.Add(globalBuff);
		}

		// Token: 0x0600124E RID: 4686 RVA: 0x0040D6FC File Offset: 0x0040B8FC
		public GlobalBuff GetGlobalBuff(string name)
		{
			GlobalBuff result;
			if (!this.globalBuffs.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x0600124F RID: 4687 RVA: 0x0000F55B File Offset: 0x0000D75B
		public T GetGlobalBuff<T>() where T : GlobalBuff
		{
			return (T)((object)this.GetGlobalBuff(typeof(T).Name));
		}

		// Token: 0x06001250 RID: 4688 RVA: 0x0040D71C File Offset: 0x0040B91C
		private void AutoloadBuff(Type type)
		{
			ModBuff modBuff = (ModBuff)Activator.CreateInstance(type);
			modBuff.mod = this;
			string name = type.Name;
			string texture = (type.Namespace + "." + type.Name).Replace('.', '/');
			if (modBuff.Autoload(ref name, ref texture))
			{
				this.AddBuff(name, modBuff, texture);
			}
		}

		// Token: 0x06001251 RID: 4689 RVA: 0x0040D778 File Offset: 0x0040B978
		private void AutoloadGlobalBuff(Type type)
		{
			GlobalBuff globalBuff = (GlobalBuff)Activator.CreateInstance(type);
			globalBuff.mod = this;
			string name = type.Name;
			if (globalBuff.Autoload(ref name))
			{
				this.AddGlobalBuff(name, globalBuff);
			}
		}

		// Token: 0x06001252 RID: 4690 RVA: 0x0040D7B4 File Offset: 0x0040B9B4
		private void AutoloadMountData(Type type)
		{
			ModMountData modMountData = (ModMountData)Activator.CreateInstance(type);
			modMountData.mod = this;
			string name = type.Name;
			string text = (type.Namespace + "." + type.Name).Replace('.', '/');
			IDictionary<MountTextureType, string> dictionary = new Dictionary<MountTextureType, string>();
			foreach (object obj in Enum.GetValues(typeof(MountTextureType)))
			{
				MountTextureType key = (MountTextureType)obj;
				dictionary[key] = text + "_" + key.ToString();
			}
			if (modMountData.Autoload(ref name, ref text, dictionary))
			{
				this.AddMount(name, modMountData, text, dictionary);
			}
		}

		// Token: 0x06001253 RID: 4691 RVA: 0x0040D890 File Offset: 0x0040BA90
		public void AddMount(string name, ModMountData mount, string texture, IDictionary<MountTextureType, string> extraTextures = null)
		{
			if (!this.loading)
			{
				throw new Exception("AddMount can only be called from Mod.Load or Mod.Autoload");
			}
			if (Mount.mounts == null || Mount.mounts.Length == 15)
			{
				Mount.Initialize();
			}
			mount.mod = this;
			mount.Name = name;
			mount.Type = MountLoader.ReserveMountID();
			mount.texture = texture;
			this.mountDatas[name] = mount;
			MountLoader.mountDatas[mount.Type] = mount;
			if (extraTextures == null)
			{
				return;
			}
			foreach (KeyValuePair<MountTextureType, string> keyValuePair in extraTextures)
			{
				if (ModLoader.TextureExists(keyValuePair.Value))
				{
					Texture2D texture2 = ModLoader.GetTexture(keyValuePair.Value);
					switch (keyValuePair.Key)
					{
					case MountTextureType.Back:
						mount.mountData.backTexture = texture2;
						break;
					case MountTextureType.BackGlow:
						mount.mountData.backTextureGlow = texture2;
						break;
					case MountTextureType.BackExtra:
						mount.mountData.backTextureExtra = texture2;
						break;
					case MountTextureType.BackExtraGlow:
						mount.mountData.backTextureExtraGlow = texture2;
						break;
					case MountTextureType.Front:
						mount.mountData.frontTexture = texture2;
						break;
					case MountTextureType.FrontGlow:
						mount.mountData.frontTextureGlow = texture2;
						break;
					case MountTextureType.FrontExtra:
						mount.mountData.frontTextureExtra = texture2;
						break;
					case MountTextureType.FrontExtraGlow:
						mount.mountData.frontTextureExtraGlow = texture2;
						break;
					}
				}
			}
		}

		// Token: 0x06001254 RID: 4692 RVA: 0x0040DA04 File Offset: 0x0040BC04
		public ModMountData GetMount(string name)
		{
			ModMountData result;
			if (!this.mountDatas.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x06001255 RID: 4693 RVA: 0x0000F577 File Offset: 0x0000D777
		public T GetMount<T>() where T : ModMountData
		{
			return (T)((object)this.GetMount(typeof(T).Name));
		}

		// Token: 0x06001256 RID: 4694 RVA: 0x0000F593 File Offset: 0x0000D793
		public int MountType(string name)
		{
			ModMountData mount = this.GetMount(name);
			if (mount == null)
			{
				return 0;
			}
			return mount.Type;
		}

		// Token: 0x06001257 RID: 4695 RVA: 0x0000F5A7 File Offset: 0x0000D7A7
		public int MountType<T>() where T : ModMountData
		{
			return this.MountType(typeof(T).Name);
		}

		// Token: 0x06001258 RID: 4696 RVA: 0x0000F5BE File Offset: 0x0000D7BE
		public void AddModWorld(string name, ModWorld modWorld)
		{
			if (!this.loading)
			{
				throw new Exception("AddModWorld can only be called from Mod.Load or Mod.Autoload");
			}
			modWorld.mod = this;
			modWorld.Name = name;
			this.worlds[name] = modWorld;
			WorldHooks.Add(modWorld);
		}

		// Token: 0x06001259 RID: 4697 RVA: 0x0040DA24 File Offset: 0x0040BC24
		private void AutoloadModWorld(Type type)
		{
			ModWorld modWorld = (ModWorld)Activator.CreateInstance(type);
			modWorld.mod = this;
			string name = type.Name;
			if (modWorld.Autoload(ref name))
			{
				this.AddModWorld(name, modWorld);
			}
		}

		// Token: 0x0600125A RID: 4698 RVA: 0x0040DA60 File Offset: 0x0040BC60
		public ModWorld GetModWorld(string name)
		{
			ModWorld result;
			if (!this.worlds.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x0600125B RID: 4699 RVA: 0x0000F5F4 File Offset: 0x0000D7F4
		public T GetModWorld<T>() where T : ModWorld
		{
			return (T)((object)this.GetModWorld(typeof(T).Name));
		}

		// Token: 0x0600125C RID: 4700 RVA: 0x0040DA80 File Offset: 0x0040BC80
		public void AddUgBgStyle(string name, ModUgBgStyle ugBgStyle)
		{
			if (!this.loading)
			{
				throw new Exception("AddUgBgStyle can only be called from Mod.Load or Mod.Autoload");
			}
			ugBgStyle.mod = this;
			ugBgStyle.Name = name;
			ugBgStyle.Slot = UgBgStyleLoader.ReserveBackgroundSlot();
			this.ugBgStyles[name] = ugBgStyle;
			UgBgStyleLoader.ugBgStyles.Add(ugBgStyle);
		}

		// Token: 0x0600125D RID: 4701 RVA: 0x0040DAD4 File Offset: 0x0040BCD4
		public ModUgBgStyle GetUgBgStyle(string name)
		{
			ModUgBgStyle result;
			if (!this.ugBgStyles.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x0600125E RID: 4702 RVA: 0x0000F610 File Offset: 0x0000D810
		public T GetUgBgStyle<T>() where T : ModUgBgStyle
		{
			return (T)((object)this.GetUgBgStyle(typeof(T).Name));
		}

		// Token: 0x0600125F RID: 4703 RVA: 0x0040DAF4 File Offset: 0x0040BCF4
		private void AutoloadUgBgStyle(Type type)
		{
			ModUgBgStyle modUgBgStyle = (ModUgBgStyle)Activator.CreateInstance(type);
			modUgBgStyle.mod = this;
			string name = type.Name;
			if (modUgBgStyle.Autoload(ref name))
			{
				this.AddUgBgStyle(name, modUgBgStyle);
			}
		}

		// Token: 0x06001260 RID: 4704 RVA: 0x0040DB30 File Offset: 0x0040BD30
		public void AddSurfaceBgStyle(string name, ModSurfaceBgStyle surfaceBgStyle)
		{
			if (!this.loading)
			{
				throw new Exception("AddSurfaceBgStyle can only be called from Mod.Load or Mod.Autoload");
			}
			surfaceBgStyle.mod = this;
			surfaceBgStyle.Name = name;
			surfaceBgStyle.Slot = SurfaceBgStyleLoader.ReserveBackgroundSlot();
			this.surfaceBgStyles[name] = surfaceBgStyle;
			SurfaceBgStyleLoader.surfaceBgStyles.Add(surfaceBgStyle);
		}

		// Token: 0x06001261 RID: 4705 RVA: 0x0040DB84 File Offset: 0x0040BD84
		public ModSurfaceBgStyle GetSurfaceBgStyle(string name)
		{
			ModSurfaceBgStyle result;
			if (!this.surfaceBgStyles.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x06001262 RID: 4706 RVA: 0x0000F62C File Offset: 0x0000D82C
		public T GetSurfaceBgStyle<T>() where T : ModSurfaceBgStyle
		{
			return (T)((object)this.GetSurfaceBgStyle(typeof(T).Name));
		}

		// Token: 0x06001263 RID: 4707 RVA: 0x0000F648 File Offset: 0x0000D848
		public int GetSurfaceBgStyleSlot(string name)
		{
			ModSurfaceBgStyle surfaceBgStyle = this.GetSurfaceBgStyle(name);
			if (surfaceBgStyle == null)
			{
				return -1;
			}
			return surfaceBgStyle.Slot;
		}

		// Token: 0x06001264 RID: 4708 RVA: 0x0000F65C File Offset: 0x0000D85C
		public int GetSurfaceBgStyleSlot<T>() where T : ModSurfaceBgStyle
		{
			return this.GetSurfaceBgStyleSlot(typeof(T).Name);
		}

		// Token: 0x06001265 RID: 4709 RVA: 0x0040DBA4 File Offset: 0x0040BDA4
		private void AutoloadSurfaceBgStyle(Type type)
		{
			ModSurfaceBgStyle modSurfaceBgStyle = (ModSurfaceBgStyle)Activator.CreateInstance(type);
			modSurfaceBgStyle.mod = this;
			string name = type.Name;
			if (modSurfaceBgStyle.Autoload(ref name))
			{
				this.AddSurfaceBgStyle(name, modSurfaceBgStyle);
			}
		}

		// Token: 0x06001266 RID: 4710 RVA: 0x0000F673 File Offset: 0x0000D873
		public void AddGlobalBgStyle(string name, GlobalBgStyle globalBgStyle)
		{
			if (!this.loading)
			{
				throw new Exception("AddGlobalBgStyle can only be called from Mod.Load or Mod.Autoload");
			}
			globalBgStyle.mod = this;
			globalBgStyle.Name = name;
			this.globalBgStyles[name] = globalBgStyle;
			GlobalBgStyleLoader.globalBgStyles.Add(globalBgStyle);
		}

		// Token: 0x06001267 RID: 4711 RVA: 0x0040DBE0 File Offset: 0x0040BDE0
		public GlobalBgStyle GetGlobalBgStyle(string name)
		{
			GlobalBgStyle result;
			if (!this.globalBgStyles.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x06001268 RID: 4712 RVA: 0x0000F6AE File Offset: 0x0000D8AE
		public T GetGlobalBgStyle<T>() where T : GlobalBgStyle
		{
			return (T)((object)this.GetGlobalBgStyle(typeof(T).Name));
		}

		// Token: 0x06001269 RID: 4713 RVA: 0x0040DC00 File Offset: 0x0040BE00
		private void AutoloadGlobalBgStyle(Type type)
		{
			GlobalBgStyle globalBgStyle = (GlobalBgStyle)Activator.CreateInstance(type);
			globalBgStyle.mod = this;
			string name = type.Name;
			if (globalBgStyle.Autoload(ref name))
			{
				this.AddGlobalBgStyle(name, globalBgStyle);
			}
		}

		// Token: 0x0600126A RID: 4714 RVA: 0x0040DC3C File Offset: 0x0040BE3C
		public void AddWaterStyle(string name, ModWaterStyle waterStyle, string texture, string blockTexture)
		{
			if (!this.loading)
			{
				throw new Exception("AddWaterStyle can only be called from Mod.Load or Mod.Autoload");
			}
			waterStyle.mod = this;
			waterStyle.Name = name;
			waterStyle.Type = WaterStyleLoader.ReserveStyle();
			waterStyle.texture = texture;
			waterStyle.blockTexture = blockTexture;
			this.waterStyles[name] = waterStyle;
			WaterStyleLoader.waterStyles.Add(waterStyle);
		}

		// Token: 0x0600126B RID: 4715 RVA: 0x0040DC9C File Offset: 0x0040BE9C
		public ModWaterStyle GetWaterStyle(string name)
		{
			ModWaterStyle result;
			if (!this.waterStyles.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x0600126C RID: 4716 RVA: 0x0000F6CA File Offset: 0x0000D8CA
		public T GetWaterStyle<T>() where T : ModWaterStyle
		{
			return (T)((object)this.GetWaterStyle(typeof(T).Name));
		}

		// Token: 0x0600126D RID: 4717 RVA: 0x0040DCBC File Offset: 0x0040BEBC
		private void AutoloadWaterStyle(Type type)
		{
			ModWaterStyle modWaterStyle = (ModWaterStyle)Activator.CreateInstance(type);
			modWaterStyle.mod = this;
			string name = type.Name;
			string text = (type.Namespace + "." + type.Name).Replace('.', '/');
			string blockTexture = text + "_Block";
			if (modWaterStyle.Autoload(ref name, ref text, ref blockTexture))
			{
				this.AddWaterStyle(name, modWaterStyle, text, blockTexture);
			}
		}

		// Token: 0x0600126E RID: 4718 RVA: 0x0040DD28 File Offset: 0x0040BF28
		public void AddWaterfallStyle(string name, ModWaterfallStyle waterfallStyle, string texture)
		{
			if (!this.loading)
			{
				throw new Exception("AddWaterfallStyle can only be called from Mod.Load or Mod.Autoload");
			}
			waterfallStyle.mod = this;
			waterfallStyle.Name = name;
			waterfallStyle.Type = WaterfallStyleLoader.ReserveStyle();
			waterfallStyle.texture = texture;
			this.waterfallStyles[name] = waterfallStyle;
			WaterfallStyleLoader.waterfallStyles.Add(waterfallStyle);
		}

		// Token: 0x0600126F RID: 4719 RVA: 0x0040DD80 File Offset: 0x0040BF80
		public ModWaterfallStyle GetWaterfallStyle(string name)
		{
			ModWaterfallStyle result;
			if (!this.waterfallStyles.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x06001270 RID: 4720 RVA: 0x0000F6E6 File Offset: 0x0000D8E6
		public T GetWaterfallStyle<T>() where T : ModWaterfallStyle
		{
			return (T)((object)this.GetWaterfallStyle(typeof(T).Name));
		}

		// Token: 0x06001271 RID: 4721 RVA: 0x0000F702 File Offset: 0x0000D902
		public int GetWaterfallStyleSlot(string name)
		{
			ModWaterfallStyle waterfallStyle = this.GetWaterfallStyle(name);
			if (waterfallStyle == null)
			{
				return -1;
			}
			return waterfallStyle.Type;
		}

		// Token: 0x06001272 RID: 4722 RVA: 0x0000F716 File Offset: 0x0000D916
		public int GetWaterfallStyleSlot<T>() where T : ModWaterfallStyle
		{
			return this.GetWaterfallStyleSlot(typeof(T).Name);
		}

		// Token: 0x06001273 RID: 4723 RVA: 0x0040DDA0 File Offset: 0x0040BFA0
		private void AutoloadWaterfallStyle(Type type)
		{
			ModWaterfallStyle modWaterfallStyle = (ModWaterfallStyle)Activator.CreateInstance(type);
			modWaterfallStyle.mod = this;
			string name = type.Name;
			string texture = (type.Namespace + "." + type.Name).Replace('.', '/');
			if (modWaterfallStyle.Autoload(ref name, ref texture))
			{
				this.AddWaterfallStyle(name, modWaterfallStyle, texture);
			}
		}

		// Token: 0x06001274 RID: 4724 RVA: 0x0040DDFC File Offset: 0x0040BFFC
		public void AddGore(string texture, ModGore modGore = null)
		{
			if (!this.loading)
			{
				throw new Exception("AddGore can only be called from Mod.Load or Mod.Autoload");
			}
			int num = ModGore.ReserveGoreID();
			ModGore.gores[texture] = num;
			if (modGore != null)
			{
				ModGore.modGores[num] = modGore;
			}
		}

		// Token: 0x06001275 RID: 4725 RVA: 0x0000F72D File Offset: 0x0000D92D
		public int GetGoreSlot(string name)
		{
			return ModGore.GetGoreSlot(this.Name + "/" + name);
		}

		// Token: 0x06001276 RID: 4726 RVA: 0x0000F745 File Offset: 0x0000D945
		public int GetGoreSlot<T>() where T : ModGore
		{
			return this.GetGoreSlot(typeof(T).Name);
		}

		// Token: 0x06001277 RID: 4727 RVA: 0x0040DE40 File Offset: 0x0040C040
		private void AutoloadGores(IList<Type> modGores)
		{
			Dictionary<string, Type> dictionary = modGores.ToDictionary((Type t) => t.Namespace + "." + t.Name);
			foreach (string text in from t in this.textures.Keys
			where t.StartsWith("Gores/")
			select t)
			{
				ModGore modGore = null;
				Type type;
				if (dictionary.TryGetValue(this.Name + "." + text.Replace('/', '.'), out type))
				{
					modGore = (ModGore)Activator.CreateInstance(type);
				}
				this.AddGore(this.Name + "/" + text, modGore);
			}
		}

		// Token: 0x06001278 RID: 4728 RVA: 0x0040DF20 File Offset: 0x0040C120
		public void AddSound(SoundType type, string soundPath, ModSound modSound = null)
		{
			if (!this.loading)
			{
				throw new Exception("AddSound can only be called from Mod.Load or Mod.Autoload");
			}
			int num = SoundLoader.ReserveSoundID(type);
			SoundLoader.sounds[type][soundPath] = num;
			if (modSound != null)
			{
				SoundLoader.modSounds[type][num] = modSound;
				modSound.sound = ModLoader.GetSound(soundPath);
			}
		}

		// Token: 0x06001279 RID: 4729 RVA: 0x0000F75C File Offset: 0x0000D95C
		public int GetSoundSlot(SoundType type, string name)
		{
			return SoundLoader.GetSoundSlot(type, this.Name + "/" + name);
		}

		// Token: 0x0600127A RID: 4730 RVA: 0x0000F775 File Offset: 0x0000D975
		public LegacySoundStyle GetLegacySoundSlot(SoundType type, string name)
		{
			return SoundLoader.GetLegacySoundSlot(type, this.Name + "/" + name);
		}

		// Token: 0x0600127B RID: 4731 RVA: 0x0040DF7C File Offset: 0x0040C17C
		private void AutoloadSounds(IList<Type> modSounds)
		{
			Dictionary<string, Type> dictionary = modSounds.ToDictionary((Type t) => t.Namespace + "." + t.Name);
			foreach (string text in from t in this.sounds.Keys
			where t.StartsWith("Sounds/")
			select t)
			{
				string text2 = text.Substring("Sounds/".Length);
				SoundType type = SoundType.Custom;
				if (text2.StartsWith("Item/"))
				{
					type = SoundType.Item;
				}
				else if (text2.StartsWith("NPCHit/"))
				{
					type = SoundType.NPCHit;
				}
				else if (text2.StartsWith("NPCKilled/"))
				{
					type = SoundType.NPCKilled;
				}
				ModSound modSound = null;
				Type type2;
				if (dictionary.TryGetValue((this.Name + "/" + text).Replace('/', '.'), out type2))
				{
					modSound = (ModSound)Activator.CreateInstance(type2);
				}
				this.AddSound(type, this.Name + "/" + text, modSound);
			}
			foreach (string text3 in from t in this.musics.Keys
			where t.StartsWith("Sounds/")
			select t)
			{
				string text4 = text3.Substring("Sounds/".Length);
				if (text4.StartsWith("Music/"))
				{
					this.AddSound(SoundType.Music, this.Name + "/" + text3, null);
				}
			}
		}

		// Token: 0x0600127C RID: 4732 RVA: 0x0000F78E File Offset: 0x0000D98E
		public void AddBackgroundTexture(string texture)
		{
			if (!this.loading)
			{
				throw new Exception("AddBackgroundTexture can only be called from Mod.Load or Mod.Autoload");
			}
			BackgroundTextureLoader.backgrounds[texture] = BackgroundTextureLoader.ReserveBackgroundSlot();
			ModLoader.GetTexture(texture);
		}

		// Token: 0x0600127D RID: 4733 RVA: 0x0000F7BA File Offset: 0x0000D9BA
		public int GetBackgroundSlot(string name)
		{
			return BackgroundTextureLoader.GetBackgroundSlot(this.Name + "/" + name);
		}

		// Token: 0x0600127E RID: 4734 RVA: 0x0040E150 File Offset: 0x0040C350
		private void AutoloadBackgrounds()
		{
			foreach (string str in from t in this.textures.Keys
			where t.StartsWith("Backgrounds/")
			select t)
			{
				this.AddBackgroundTexture(this.Name + "/" + str);
			}
		}

		// Token: 0x0600127F RID: 4735 RVA: 0x0000F7D2 File Offset: 0x0000D9D2
		public void AddGlobalRecipe(string name, GlobalRecipe globalRecipe)
		{
			if (!this.loading)
			{
				throw new Exception("AddGlobalRecipe can only be called from Mod.Load or Mod.Autoload");
			}
			globalRecipe.mod = this;
			globalRecipe.Name = name;
			this.globalRecipes[name] = globalRecipe;
			RecipeHooks.Add(globalRecipe);
		}

		// Token: 0x06001280 RID: 4736 RVA: 0x0040E1D8 File Offset: 0x0040C3D8
		private void AutoloadGlobalRecipe(Type type)
		{
			GlobalRecipe globalRecipe = (GlobalRecipe)Activator.CreateInstance(type);
			globalRecipe.mod = this;
			string name = type.Name;
			if (globalRecipe.Autoload(ref name))
			{
				this.AddGlobalRecipe(name, globalRecipe);
			}
		}

		// Token: 0x06001281 RID: 4737 RVA: 0x0000F808 File Offset: 0x0000DA08
		public void AddCommand(string name, ModCommand mc)
		{
			if (!this.loading)
			{
				throw new Exception("AddCommand can only be called from Mod.Load or Mod.Autoload");
			}
			mc.mod = this;
			mc.Name = name;
			CommandManager.Add(mc);
		}

		// Token: 0x06001282 RID: 4738 RVA: 0x0040E214 File Offset: 0x0040C414
		private void AutoloadCommand(Type type)
		{
			ModCommand modCommand = (ModCommand)Activator.CreateInstance(type);
			modCommand.mod = this;
			string name = type.Name;
			if (modCommand.Autoload(ref name))
			{
				this.AddCommand(name, modCommand);
			}
		}

		// Token: 0x06001283 RID: 4739 RVA: 0x0040E250 File Offset: 0x0040C450
		public GlobalRecipe GetGlobalRecipe(string name)
		{
			GlobalRecipe result;
			if (!this.globalRecipes.TryGetValue(name, out result))
			{
				return null;
			}
			return result;
		}

		// Token: 0x06001284 RID: 4740 RVA: 0x0000F831 File Offset: 0x0000DA31
		public T GetGlobalRecipe<T>() where T : GlobalRecipe
		{
			return (T)((object)this.GetGlobalRecipe(typeof(T).Name));
		}

		// Token: 0x06001285 RID: 4741 RVA: 0x0040E270 File Offset: 0x0040C470
		public void AddMusicBox(int musicSlot, int itemType, int tileType, int tileFrameY = 0)
		{
			if (!this.loading)
			{
				throw new Exception("AddMusicBox can only be called from Mod.Load or Mod.Autoload");
			}
			if (musicSlot < 42)
			{
				throw new ArgumentOutOfRangeException("Cannot assign music box to vanilla music ID " + musicSlot);
			}
			if (musicSlot >= SoundLoader.SoundCount(SoundType.Music))
			{
				throw new ArgumentOutOfRangeException("Music ID " + musicSlot + " does not exist");
			}
			if (itemType < 3930)
			{
				throw new ArgumentOutOfRangeException("Cannot assign music box to vanilla item ID " + itemType);
			}
			if (ItemLoader.GetItem(itemType) == null)
			{
				throw new ArgumentOutOfRangeException("Item ID " + itemType + " does not exist");
			}
			if (tileType < 470)
			{
				throw new ArgumentOutOfRangeException("Cannot assign music box to vanilla tile ID " + tileType);
			}
			if (TileLoader.GetTile(tileType) == null)
			{
				throw new ArgumentOutOfRangeException("Tile ID " + tileType + " does not exist");
			}
			if (SoundLoader.musicToItem.ContainsKey(musicSlot))
			{
				throw new ArgumentException("Music ID " + musicSlot + " has already been assigned a music box");
			}
			if (SoundLoader.itemToMusic.ContainsKey(itemType))
			{
				throw new ArgumentException("Item ID " + itemType + " has already been assigned a music");
			}
			if (!SoundLoader.tileToMusic.ContainsKey(tileType))
			{
				SoundLoader.tileToMusic[tileType] = new Dictionary<int, int>();
			}
			if (SoundLoader.tileToMusic[tileType].ContainsKey(tileFrameY))
			{
				string message = string.Concat(new object[]
				{
					"Y-frame ",
					tileFrameY,
					" of tile type ",
					tileType,
					" has already been assigned a music"
				});
				throw new ArgumentException(message);
			}
			if (tileFrameY % 36 != 0)
			{
				throw new ArgumentException("Y-frame must be divisible by 36");
			}
			SoundLoader.musicToItem[musicSlot] = itemType;
			SoundLoader.itemToMusic[itemType] = musicSlot;
			SoundLoader.tileToMusic[tileType][tileFrameY] = musicSlot;
		}

		// Token: 0x06001286 RID: 4742 RVA: 0x0000F84D File Offset: 0x0000DA4D
		public ModHotKey RegisterHotKey(string name, string defaultKey)
		{
			if (!this.loading)
			{
				throw new Exception("RegisterHotKey can only be called from Mod.Load or Mod.Autoload");
			}
			return ModLoader.RegisterHotKey(this, name, defaultKey);
		}

		// Token: 0x06001287 RID: 4743 RVA: 0x0000F86A File Offset: 0x0000DA6A
		public ModTranslation CreateTranslation(string key)
		{
			key = string.Format("Mods.{0}.{1}", this.Name, key);
			return new ModTranslation(key, false);
		}

		// Token: 0x06001288 RID: 4744 RVA: 0x0000F886 File Offset: 0x0000DA86
		public void AddTranslation(ModTranslation translation)
		{
			this.translations[translation.Key] = translation;
		}

		// Token: 0x06001289 RID: 4745 RVA: 0x0040E450 File Offset: 0x0040C650
		internal void SetupContent()
		{
			foreach (ModItem modItem in this.items.Values)
			{
				ItemLoader.SetDefaults(modItem.item, false);
				modItem.AutoStaticDefaults();
				modItem.SetStaticDefaults();
			}
			foreach (ModPrefix modPrefix in this.prefixes.Values)
			{
				modPrefix.AutoDefaults();
				modPrefix.SetDefaults();
			}
			foreach (ModDust modDust in this.dusts.Values)
			{
				modDust.SetDefaults();
			}
			foreach (ModTile modTile in this.tiles.Values)
			{
				Main.tileTexture[(int)modTile.Type] = ModLoader.GetTexture(modTile.texture);
				TileLoader.SetDefaults(modTile);
				if (TileID.Sets.HasOutlines[(int)modTile.Type])
				{
					Main.highlightMaskTexture[(int)modTile.Type] = ModLoader.GetTexture(modTile.HighlightTexture);
				}
				if (!string.IsNullOrEmpty(modTile.chest))
				{
					TileID.Sets.BasicChest[(int)modTile.Type] = true;
				}
			}
			foreach (GlobalTile globalTile in this.globalTiles.Values)
			{
				globalTile.SetDefaults();
			}
			foreach (ModWall modWall in this.walls.Values)
			{
				Main.wallTexture[(int)modWall.Type] = ModLoader.GetTexture(modWall.texture);
				modWall.SetDefaults();
			}
			foreach (GlobalWall globalWall in this.globalWalls.Values)
			{
				globalWall.SetDefaults();
			}
			foreach (ModProjectile modProjectile in this.projectiles.Values)
			{
				ProjectileLoader.SetDefaults(modProjectile.projectile, false);
				modProjectile.AutoStaticDefaults();
				modProjectile.SetStaticDefaults();
			}
			foreach (ModNPC modNPC in this.npcs.Values)
			{
				NPCLoader.SetDefaults(modNPC.npc, false);
				modNPC.AutoStaticDefaults();
				modNPC.SetStaticDefaults();
			}
			foreach (ModMountData modMountData in this.mountDatas.Values)
			{
				Mount.MountData mountData = modMountData.mountData;
				mountData.modMountData = modMountData;
				MountLoader.SetupMount(mountData);
				Mount.mounts[modMountData.Type] = mountData;
			}
			foreach (ModBuff modBuff in this.buffs.Values)
			{
				Main.buffTexture[modBuff.Type] = ModLoader.GetTexture(modBuff.texture);
				modBuff.SetDefaults();
			}
			foreach (ModWaterStyle modWaterStyle in this.waterStyles.Values)
			{
				LiquidRenderer.Instance._liquidTextures[modWaterStyle.Type] = ModLoader.GetTexture(modWaterStyle.texture);
				Main.liquidTexture[modWaterStyle.Type] = ModLoader.GetTexture(modWaterStyle.blockTexture);
			}
			foreach (ModWaterfallStyle modWaterfallStyle in this.waterfallStyles.Values)
			{
				Main.instance.waterfallManager.waterfallTexture[modWaterfallStyle.Type] = ModLoader.GetTexture(modWaterfallStyle.texture);
			}
		}

		// Token: 0x0600128A RID: 4746 RVA: 0x0040E92C File Offset: 0x0040CB2C
		internal void UnloadContent()
		{
			this.Unload();
			this.recipes.Clear();
			this.items.Clear();
			this.globalItems.Clear();
			this.equipTextures.Clear();
			this.prefixes.Clear();
			this.dusts.Clear();
			this.tiles.Clear();
			this.globalTiles.Clear();
			this.tileEntities.Clear();
			this.walls.Clear();
			this.globalWalls.Clear();
			this.players.Clear();
			this.projectiles.Clear();
			this.globalProjectiles.Clear();
			this.npcs.Clear();
			this.globalNPCs.Clear();
			this.buffs.Clear();
			this.globalBuffs.Clear();
			this.mountDatas.Clear();
			this.worlds.Clear();
			this.ugBgStyles.Clear();
			this.surfaceBgStyles.Clear();
			this.globalBgStyles.Clear();
			this.waterStyles.Clear();
			this.waterfallStyles.Clear();
			this.globalRecipes.Clear();
			this.translations.Clear();
			bool dedServ = Main.dedServ;
			this.sounds.Clear();
			this.effects.Clear();
			foreach (Texture2D texture2D in this.textures.Values)
			{
				if (texture2D != null)
				{
					texture2D.Dispose();
				}
			}
			this.textures.Clear();
			this.musics.Clear();
			this.fonts.Clear();
		}

		// Token: 0x0600128B RID: 4747 RVA: 0x0000F89A File Offset: 0x0000DA9A
		public byte[] GetFileBytes(string name)
		{
			TmodFile file = this.File;
			if (file == null)
			{
				return null;
			}
			return file.GetFile(name);
		}

		// Token: 0x0600128C RID: 4748 RVA: 0x0000F8AE File Offset: 0x0000DAAE
		public bool FileExists(string name)
		{
			return this.File != null && this.File.HasFile(name);
		}

		// Token: 0x0600128D RID: 4749 RVA: 0x0040EAEC File Offset: 0x0040CCEC
		public Texture2D GetTexture(string name)
		{
			Texture2D result;
			if (!this.textures.TryGetValue(name, out result))
			{
				throw new MissingResourceException(name, this.textures.Keys);
			}
			return result;
		}

		// Token: 0x0600128E RID: 4750 RVA: 0x0000F8C6 File Offset: 0x0000DAC6
		public bool TextureExists(string name)
		{
			return this.textures.ContainsKey(name);
		}

		// Token: 0x0600128F RID: 4751 RVA: 0x0000F8D4 File Offset: 0x0000DAD4
		public void AddTexture(string name, Texture2D texture)
		{
			if (this.TextureExists(name))
			{
				throw new ModNameException("Texture already exist: " + name);
			}
			this.textures[name] = texture;
		}

		// Token: 0x06001290 RID: 4752 RVA: 0x0040EB1C File Offset: 0x0040CD1C
		public SoundEffect GetSound(string name)
		{
			SoundEffect result;
			if (!this.sounds.TryGetValue(name, out result))
			{
				throw new MissingResourceException(name);
			}
			return result;
		}

		// Token: 0x06001291 RID: 4753 RVA: 0x0000F8FD File Offset: 0x0000DAFD
		public bool SoundExists(string name)
		{
			return this.sounds.ContainsKey(name);
		}

		// Token: 0x06001292 RID: 4754 RVA: 0x0040EB44 File Offset: 0x0040CD44
		public Music GetMusic(string name)
		{
			MusicData musicData;
			if (!this.musics.TryGetValue(name, out musicData))
			{
				throw new MissingResourceException(name);
			}
			return musicData.GetInstance();
		}

		// Token: 0x06001293 RID: 4755 RVA: 0x0000F90B File Offset: 0x0000DB0B
		public bool MusicExists(string name)
		{
			return this.musics.ContainsKey(name);
		}

		// Token: 0x06001294 RID: 4756 RVA: 0x0040EB70 File Offset: 0x0040CD70
		public DynamicSpriteFont GetFont(string name)
		{
			DynamicSpriteFont result;
			if (!this.fonts.TryGetValue(name, out result))
			{
				throw new MissingResourceException(name);
			}
			return result;
		}

		// Token: 0x06001295 RID: 4757 RVA: 0x0000F919 File Offset: 0x0000DB19
		public bool FontExists(string name)
		{
			return this.fonts.ContainsKey(name);
		}

		// Token: 0x06001296 RID: 4758 RVA: 0x0040EB98 File Offset: 0x0040CD98
		public Effect GetEffect(string name)
		{
			Effect result;
			if (!this.effects.TryGetValue(name, out result))
			{
				throw new MissingResourceException(name);
			}
			return result;
		}

		// Token: 0x06001297 RID: 4759 RVA: 0x0040EBC0 File Offset: 0x0040CDC0
		private void AutoloadLocalization()
		{
			Dictionary<string, ModTranslation> dictionary = new Dictionary<string, ModTranslation>();
			IEnumerable<KeyValuePair<string, byte[]>> enumerable = from x in this.File
			where Path.GetExtension(x.Key) == ".lang"
			select x;
			foreach (KeyValuePair<string, byte[]> keyValuePair in enumerable)
			{
				string @string = Encoding.UTF8.GetString(keyValuePair.Value);
				GameCulture culture = GameCulture.FromName(Path.GetFileNameWithoutExtension(keyValuePair.Key));
				using (StringReader stringReader = new StringReader(@string))
				{
					string text;
					while ((text = stringReader.ReadLine()) != null)
					{
						int num = text.IndexOf('=');
						if (num >= 0)
						{
							string key = text.Substring(0, num).Trim().Replace(" ", "_");
							string text2 = text.Substring(num + 1).Trim();
							if (text2.Length != 0)
							{
								text2 = text2.Replace("\\n", "\n");
								ModTranslation modTranslation;
								if (!dictionary.TryGetValue(key, out modTranslation))
								{
									modTranslation = (dictionary[key] = this.CreateTranslation(key));
								}
								modTranslation.AddTranslation(culture, text2);
							}
						}
					}
				}
			}
			foreach (ModTranslation translation in dictionary.Values)
			{
				this.AddTranslation(translation);
			}
		}

		// Token: 0x06001298 RID: 4760 RVA: 0x0000F927 File Offset: 0x0000DB27
		public bool EffectExists(string name)
		{
			return this.effects.ContainsKey(name);
		}

		// Token: 0x06001299 RID: 4761 RVA: 0x0000D858 File Offset: 0x0000BA58
		public virtual object Call(params object[] args)
		{
			return null;
		}

		// Token: 0x0600129A RID: 4762 RVA: 0x0040ED64 File Offset: 0x0040CF64
		public ModPacket GetPacket(int capacity = 256)
		{
			if (this.netID < 0)
			{
				throw new Exception("Cannot get packet for " + this.Name + " because it does not exist on the other side");
			}
			ModPacket modPacket = new ModPacket(250, capacity + 5);
			modPacket.Write(this.netID);
			return modPacket;
		}

		// Token: 0x0600129B RID: 4763 RVA: 0x0000F935 File Offset: 0x0000DB35
		public virtual void UpdateMusic(ref int music, ref MusicPriority priority)
		{
			this.UpdateMusic(ref music);
		}

		// Token: 0x0600129C RID: 4764 RVA: 0x00006B58 File Offset: 0x00004D58
		[Obsolete("This UpdateMusic method now obsolete, use the UpdateMusic with the MusicPriority parameter.")]
		public virtual void UpdateMusic(ref int music)
		{
		}

		// Token: 0x0600129D RID: 4765 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void HotKeyPressed(string name)
		{
		}

		// Token: 0x0600129E RID: 4766 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void HandlePacket(BinaryReader reader, int whoAmI)
		{
		}

		// Token: 0x0600129F RID: 4767 RVA: 0x0000ADF8 File Offset: 0x00008FF8
		public virtual bool HijackGetData(ref byte messageType, ref BinaryReader reader, int playerNumber)
		{
			return false;
		}

		// Token: 0x060012A0 RID: 4768 RVA: 0x0000ADF8 File Offset: 0x00008FF8
		public virtual bool HijackSendData(int whoAmI, int msgType, int remoteClient, int ignoreClient, NetworkText text, int number, float number2, float number3, float number4, int number5, int number6, int number7)
		{
			return false;
		}

		// Token: 0x060012A1 RID: 4769 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
		{
		}

		// Token: 0x060012A2 RID: 4770 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void UpdateUI(GameTime gameTime)
		{
		}

		// Token: 0x060012A3 RID: 4771 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void ModifyInterfaceLayers(List<GameInterfaceLayer> layers)
		{
		}

		// Token: 0x060012A4 RID: 4772 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void ModifySunLightColor(ref Color tileColor, ref Color backgroundColor)
		{
		}

		// Token: 0x060012A5 RID: 4773 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void ModifyLightingBrightness(ref float scale)
		{
		}

		// Token: 0x060012A6 RID: 4774 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void PostDrawInterface(SpriteBatch spriteBatch)
		{
		}

		// Token: 0x060012A7 RID: 4775 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void PostDrawFullscreenMap(ref string mouseText)
		{
		}

		// Token: 0x060012A8 RID: 4776 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void PostUpdateInput()
		{
		}

		// Token: 0x060012A9 RID: 4777 RVA: 0x00006B58 File Offset: 0x00004D58
		public virtual void PreSaveAndQuit()
		{
		}

		// Token: 0x04001400 RID: 5120
		internal short netID = -1;

		// Token: 0x04001401 RID: 5121
		internal bool loading;

		// Token: 0x04001402 RID: 5122
		private Queue<Task> AsyncLoadQueue = new Queue<Task>();

		// Token: 0x04001403 RID: 5123
		internal readonly IDictionary<string, Texture2D> textures = new Dictionary<string, Texture2D>();

		// Token: 0x04001404 RID: 5124
		internal readonly IDictionary<string, SoundEffect> sounds = new Dictionary<string, SoundEffect>();

		// Token: 0x04001405 RID: 5125
		internal readonly IDictionary<string, MusicData> musics = new Dictionary<string, MusicData>();

		// Token: 0x04001406 RID: 5126
		internal readonly IDictionary<string, DynamicSpriteFont> fonts = new Dictionary<string, DynamicSpriteFont>();

		// Token: 0x04001407 RID: 5127
		internal readonly IDictionary<string, Effect> effects = new Dictionary<string, Effect>();

		// Token: 0x04001408 RID: 5128
		internal readonly IList<ModRecipe> recipes = new List<ModRecipe>();

		// Token: 0x04001409 RID: 5129
		internal readonly IDictionary<string, ModItem> items = new Dictionary<string, ModItem>();

		// Token: 0x0400140A RID: 5130
		internal readonly IDictionary<string, GlobalItem> globalItems = new Dictionary<string, GlobalItem>();

		// Token: 0x0400140B RID: 5131
		internal readonly IDictionary<Tuple<string, EquipType>, EquipTexture> equipTextures = new Dictionary<Tuple<string, EquipType>, EquipTexture>();

		// Token: 0x0400140C RID: 5132
		internal readonly IDictionary<string, ModPrefix> prefixes = new Dictionary<string, ModPrefix>();

		// Token: 0x0400140D RID: 5133
		internal readonly IDictionary<string, ModDust> dusts = new Dictionary<string, ModDust>();

		// Token: 0x0400140E RID: 5134
		internal readonly IDictionary<string, ModTile> tiles = new Dictionary<string, ModTile>();

		// Token: 0x0400140F RID: 5135
		internal readonly IDictionary<string, GlobalTile> globalTiles = new Dictionary<string, GlobalTile>();

		// Token: 0x04001410 RID: 5136
		internal readonly IDictionary<string, ModTileEntity> tileEntities = new Dictionary<string, ModTileEntity>();

		// Token: 0x04001411 RID: 5137
		internal readonly IDictionary<string, ModWall> walls = new Dictionary<string, ModWall>();

		// Token: 0x04001412 RID: 5138
		internal readonly IDictionary<string, GlobalWall> globalWalls = new Dictionary<string, GlobalWall>();

		// Token: 0x04001413 RID: 5139
		internal readonly IDictionary<string, ModProjectile> projectiles = new Dictionary<string, ModProjectile>();

		// Token: 0x04001414 RID: 5140
		internal readonly IDictionary<string, GlobalProjectile> globalProjectiles = new Dictionary<string, GlobalProjectile>();

		// Token: 0x04001415 RID: 5141
		internal readonly IDictionary<string, ModNPC> npcs = new Dictionary<string, ModNPC>();

		// Token: 0x04001416 RID: 5142
		internal readonly IDictionary<string, GlobalNPC> globalNPCs = new Dictionary<string, GlobalNPC>();

		// Token: 0x04001417 RID: 5143
		internal readonly IDictionary<string, ModPlayer> players = new Dictionary<string, ModPlayer>();

		// Token: 0x04001418 RID: 5144
		internal readonly IDictionary<string, ModMountData> mountDatas = new Dictionary<string, ModMountData>();

		// Token: 0x04001419 RID: 5145
		internal readonly IDictionary<string, ModBuff> buffs = new Dictionary<string, ModBuff>();

		// Token: 0x0400141A RID: 5146
		internal readonly IDictionary<string, GlobalBuff> globalBuffs = new Dictionary<string, GlobalBuff>();

		// Token: 0x0400141B RID: 5147
		internal readonly IDictionary<string, ModWorld> worlds = new Dictionary<string, ModWorld>();

		// Token: 0x0400141C RID: 5148
		internal readonly IDictionary<string, ModUgBgStyle> ugBgStyles = new Dictionary<string, ModUgBgStyle>();

		// Token: 0x0400141D RID: 5149
		internal readonly IDictionary<string, ModSurfaceBgStyle> surfaceBgStyles = new Dictionary<string, ModSurfaceBgStyle>();

		// Token: 0x0400141E RID: 5150
		internal readonly IDictionary<string, GlobalBgStyle> globalBgStyles = new Dictionary<string, GlobalBgStyle>();

		// Token: 0x0400141F RID: 5151
		internal readonly IDictionary<string, ModWaterStyle> waterStyles = new Dictionary<string, ModWaterStyle>();

		// Token: 0x04001420 RID: 5152
		internal readonly IDictionary<string, ModWaterfallStyle> waterfallStyles = new Dictionary<string, ModWaterfallStyle>();

		// Token: 0x04001421 RID: 5153
		internal readonly IDictionary<string, GlobalRecipe> globalRecipes = new Dictionary<string, GlobalRecipe>();

		// Token: 0x04001422 RID: 5154
		internal readonly IDictionary<string, ModTranslation> translations = new Dictionary<string, ModTranslation>();
	}
}
